/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

//This class was meant to notice button clicks, but we were not able
//to get this to work 100% correctly, so this class is never used
package controller;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import model.Course;
import org.xml.sax.SAXException;

//@WebServlet("/myservlet")
public class MyServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        
            response.setContentType("text/html");
            PrintWriter out = response.getWriter();
            String btn = request.getParameter("btnCreateCourse");
            if(btn!=null){

                String name = request.getParameter("name");
                String cp = request.getParameter("credits");
                int credits = Integer.parseInt(cp);
                String type = request.getParameter("type");
                String description = request.getParameter("desc");
                
                Course c = new Course("kursname", 5, "beschreibung", "informatics");
                
                Coursemanagement cm = new Coursemanagement();
            
                /* Course Array speichern
                   cm.saveCourse(c); */
                request.getRequestDispatcher("viewCourses.jsp").forward(request, response);
            } 
       }
}